package cn.iocoder.yudao.module.reservation.dal.mysql.promotionactivity;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.reservation.dal.dataobject.promotionactivity.PromotionActivityDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.reservation.controller.admin.promotionactivity.vo.*;

/**
 * 优惠活动 Mapper
 *
 * @author yy
 */
@Mapper
public interface PromotionActivityMapper extends BaseMapperX<PromotionActivityDO> {

    default PageResult<PromotionActivityDO> selectPage(PromotionActivityPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PromotionActivityDO>()
                .eqIfPresent(PromotionActivityDO::getActivityType, reqVO.getActivityType())
                .eqIfPresent(PromotionActivityDO::getMinAmount, reqVO.getMinAmount())
                .eqIfPresent(PromotionActivityDO::getGiftType, reqVO.getGiftType())
                .eqIfPresent(PromotionActivityDO::getGiftValue, reqVO.getGiftValue())
                .betweenIfPresent(PromotionActivityDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(PromotionActivityDO::getEndTime, reqVO.getEndTime())
                .orderByDesc(PromotionActivityDO::getId));
    }

}